package insight.google.game.era.client.proxy;

import java.util.Collection;
import java.util.HashMap;

import org.directwebremoting.proxy.ScriptProxy;

public class HostClientProxyImpl implements HostClientProxy {

	
	 /**
	 * 
	 */
	protected static HostClientProxy hostClientProxy;
	    
	    public static HostClientProxy getInstance(){
	        if(hostClientProxy == null){
	        	hostClientProxy = new HostClientProxyImpl();
	        }
	        return hostClientProxy;
	    }
	public void showGameRoom(ScriptProxy userProxy, String jsComponentId,
			Object param) {
		// TODO Auto-generated method stub
		userProxy.addFunctionCall("componentExecFunctionWithCall",jsComponentId,"joinGame",param);
		
	}

	public  void notifyUser(ScriptProxy userProxy, String jsComponentId,
			Object param) {
		

	}

	public  void showMainPage(ScriptProxy userProxy, String jsComponentId,
			Object param) {
//		HashMap<String, Collection<? extends Object>> data = new HashMap<String, Collection<? extends Object>>();
//		
////		((HashMap<String,Object>)((HashMap<String,Object>)param).get("roomlist")).values()
//		
//		if((((HashMap<String,Object>)((HashMap<String,Object>)param).get("roomlist")).values())!=null){
//			data.put("roomlist",(((HashMap<String,Object>)((HashMap<String,Object>)param).get("roomlist")).values()));
//		}
//		
//		
//		data.put("userlist",(((HashMap<String,Object>)((HashMap<String,Object>)param).get("userlist")).values()));
		//data.put("msglist",(((HashMap<String,Object>)((HashMap<String,Object>)param).get("msglist")).values()));
		
		userProxy.addFunctionCall("componentExecFunctionWithCall",jsComponentId,"initMainPage",param);

	}

	public void userLogout(ScriptProxy userProxy, String jsComponentId,
			Object param) {
		
		userProxy.addFunctionCall("componentExecFunctionWithCall",jsComponentId,"afterLogout",param);
	}
	@Override
	public void errorMsgShow(ScriptProxy userProxy, String jsComponentId,
			String error) {
		// TODO Auto-generated method stub
		userProxy.addFunctionCall("componentExecFunctionWithCall",jsComponentId,"errorMsgShow", error);
	}
	@Override
	public void publicDataVersion(ScriptProxy userProxy, String jsComponentId,
			long dataVersion) {
		// TODO Auto-generated method stub
		userProxy.addFunctionCall("componentExecFunctionWithCall",jsComponentId,"updateDataVersion",dataVersion);
	}
	
	@Override
	public void updateRoomList(ScriptProxy userProxy, String jsComponentId,
			Object param) {
		userProxy.addFunctionCall("componentExecFunctionWithCall","roomListModel_instance","updateRoomList",param);
		
	}

	@Override
	public void updateUserList(ScriptProxy userProxy, String jsComponentId,
			Object param) {
		 userProxy.addFunctionCall("componentExecFunctionWithCall","userListModel_instance","updateRoomList",param);
		
	}
	

}
